package com.atguigui.leetcode1;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * 2347.最好的扑克手牌
 * Project: leetcode
 * Package: com.atguigui.leetcode1
 * Version: 1.0
 * <p>
 * Created by WJX on 2023/2/20 9:03
 */
public class P2347BestPokerHand {
    public static void main(String[] args) {
        Solution solution = new P2347BestPokerHand().new Solution();
        // TO TEST
    }

    class Solution {
        public String bestHand(int[] ranks, char[] suits) {
            String[] ans = {"Flush", "Three of a Kind", "Pair", "High Card"};
            Set<Character> suitsSet = new HashSet<Character>();
            for (char suit : suits) {
                suitsSet.add(suit);
            }
            if (suitsSet.size() == 1) return "Flush";
            Map<Integer, Integer> h = new HashMap<Integer, Integer>();
            for (int rank : ranks) {
                h.put(rank, h.getOrDefault(rank, 0) + 1);
            }
            if (h.size() == 5) return "High Card";

            for (Map.Entry<Integer, Integer> entry : h.entrySet()) {
                if (entry.getValue() > 2) {
                    return "Three of a Kind";
                }
            }

            return "Pair";
        }
    }
}
